package com.pruebas.andEngine;

import org.anddev.andengine.engine.handler.physics.PhysicsHandler;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

public class TelefonoRojo extends AnimatedSprite{
	private final PhysicsHandler mPhysicsHandler;
	private Float posicionActual;
	static final int DESPLAZAMIENTOX = 10;
	private Boolean isColisioned = false;
	
	public TelefonoRojo(float pX, float pY, TiledTextureRegion pTiledTextureRegion) {
		super(pX, pY, pTiledTextureRegion);
		this.mPhysicsHandler = new PhysicsHandler(this);
	    this.registerUpdateHandler(this.mPhysicsHandler);
	}
	
	public boolean moveSprite(int valor){
		if(!isColisioned){
			posicionActual = this.getX();
	        this.setPosition(posicionActual - (DESPLAZAMIENTOX + valor), this.getY());
	        
	        if(this.getX() <= -this.getWidth()){
	      	  this.stopAnimation();
	      	  return false;
	        }
	        return true;
		}
		else{
			this.setVisible(false);
			this.stopAnimation();
			this.reset();
			isColisioned = false;
			return false;
		}
	}

	public Boolean getIsColisioned() {
		return isColisioned;
	}

	public void setIsColisioned(Boolean isColisioned) {
		this.isColisioned = isColisioned;
	}
}
